<?php

namespace App\Http\Controllers\Ceb;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Ceb\BaseController as Controller;
use App\Models\ChannelProvider;
use Route;

class ChannelProviderController extends Controller
{
    
    public function __construct() {
        
    }
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $int_PageSize = $request->get('page_size',10);
        $arr_Channel = ChannelProvider::with('channel')->forPage(1,$int_PageSize)->orderBy('created_at','desc')->get();
        return $this->view('channel-provider.index',[
            'channel_list' => $arr_Channel
        ]);
    }
    
    public function create(){
        return $this->view('channel-provider.create');
    }
    
    public function store(Request $request){
        $this->validate($request, [
            'name' => 'required|string|unique:channel_providers'
        ]);
        $mod_ChannelProvider = ChannelProvider::create($request->all());
        return redirect('ceb/channels/create?channel_provider_id=' . $mod_ChannelProvider->id);
    }

}
